<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>搜索测试后台-关键字处理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${request.contextPath}/css/style.css">
	<script type="text/javascript" src="${request.contextPath}/js/jquery-1.6.1.min.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/main.js"></script>
	
	<script type="text/javascript">
	
	$(function(){
		listGoods(0);
	});
	var oldS = 0;
	var pageTotal = 0;
	var currentp = 1;
	function listGoods(n, cp){
		currentp = cp || 1;
		n = n || 0;
		oldS = n;
		var kid = $('#keyId').val();
		jQuery.ajax({
			url : 'tgoods?keyword=' + kid + '&status=' + n + '&date=' + new Date().getTime() + '&cp=' + currentp,
			type : 'GET',
			success : function(json) {
				var h = '<ul style="margin-left:-10px;">';
				if(json && json.length > 5) {
					pageTotal = 0;
					var objs = eval(json);
					
					var cnt = 0;
					for(var i = 0, len = objs.length; i < len; i ++) {
						cnt ++;
						var o = objs[i];
						var title = o.goodsTitle;
						var gsn = o.goodsSn;
						var kid = o.keyId;
						var img = imgBase + o.img;
						var id = o.id;
						
						var c = o.cateNames;
						
						var okStyle = '';
						var noStyle = '';
						if(n == 1) {
							okStyle = 'style="display:none;"';
							$('#batchOk').fadeOut(0);
							$('#batchNo').fadeIn(0);
						}else if(n == 2) {
							noStyle = 'style="display:none;"';
							$('#batchOk').fadeIn(0);
							$('#batchNo').fadeOut(0);
						}else{
							$('#batchOk,#batchNo').fadeIn(0);
						}
						
						var newName = 'goods_'+cnt;
						
						h += '<li class="floatLi" id="'+gsn+'">' +
							 '	<img src="'+img+'" width="120" height="120" />' +
							 '	<div style="width:150px;height:55px;margin-top:10px;overflow:hidden;">'+title+'</div>' +
							 '	<div style="width:150px;height:45px;margin-top:10px;overflow:hidden;">'+c+'</div>' +
							 '	<div style="width:150px;">'+
							 '		<input type="checkbox" id="'+newName+'" value="'+gsn+'" class="box1" /><label for="'+newName+'">'+gsn+'</label>&nbsp;'+
							 '		<a class="operateClassA" href="javascript:void(0);" '+noStyle+' onclick="setStatus(2,\''+gsn+'\');">错误</a>&nbsp;'+
							 '		<a class="operateClassB" href="javascript:void(0);" '+okStyle+' onclick="setStatus(1,\''+gsn+'\');">正确</a>'+
							 '	</div>' +
							 '</li>';
						pageTotal ++;
					}
					
					$('#moreDiv,#prev,#next').fadeIn(0);
					if(currentp <= 1){
						$('#prev').fadeOut(0);
					}
					if(cnt < 40){
						$('#next').fadeOut(0);
					}
				}else{
					h += '没有数据...';
					if(currentp <= 1){
						$('#moreDiv').fadeOut(0);
					}else{
						$('#moreDiv,#prev').fadeIn(0);
						$('#next').fadeOut(0);
					}
				}
				h += '</ul>';
				$('#div' + '0').html(h);
				$('#tab' + n).addClass('tabOn');
				$('#tab' + n).siblings("[id*=tab]").removeClass('tabOn');
			}
		});
	}
	
	function more() {
		currentp ++;
		listGoods(oldS, currentp);
	}
	function less() {
		currentp --;
		listGoods(oldS, currentp);
	}
	function selectAll(n){
		n = n || 0;
		if(n > 0) {
			$('input.box1').attr('checked', true);
		}else if (n < 0){
			$('input.box1').each(function(){
				var o = $(this);
				o.attr('checked', !o.attr('checked'));
			});
		}else{
			$('input.box1').attr('checked', false);
		}
	}
	
	function setStatus(n, gsn){
		var kid = $('#keyId').val();
		gsn = gsn || getGsns();
		if(n == null || n == undefined || n < 1 || n > 2 || gsn == null) {
			return;
		}
		var delt = gsn.split(',').length;
		jQuery.ajax({
			url : 'tsetStatus?keyword=' + kid + '&status=' + n + '&gsn=' + gsn,
			type : 'post',
			success : function(rs) {
				if(rs == 1) {
					var ukn = $('#unNum').html() - 0;
					var okn = $('#okNum').html() - 0;
					var nkn = $('#noNum').html() - 0;
					if(n == 1){
						okn = okn + delt;
						$('#okNum').html(okn);
					}else if(n == 2){
						nkn = nkn + delt;
						$('#noNum').html(nkn);
					}
					if(oldS == 0){
						ukn = ukn - delt;
						$('#unNum').html(ukn);
					}else if(oldS == 1){
						okn = okn - delt;
						$('#okNum').html(okn);
					}else{
						nkn = nkn - delt;
						$('#noNum').html(nkn);
					}
					var gsns = gsn.split(',');
					for(var i = 0; i < gsns.length; i ++) {
						$('#'+ gsns[i]).remove();
						pageTotal --;
					}
					if(pageTotal <= 5) {
						listGoods(oldS);
					}
				}else{
					
				}
			}
		});
	}
	function getGsns() {
		var selected = $('input.box1').filter(':checked');
		var rs =  selected.map(function(){
			return $(this).val();
		}).get().join(',');
		
		return rs;
	}
	</script>
  </head>
  
  <body>
  	<div class="mainDiv" style="text-align:left;">
  		<#if keyInfo?exists>
  			<input type="hidden" value="${keyInfo.id}" id="keyId" />
	  		<span id="topDiv" style="font-size:17px;">关键字 ： 
	  			<span style="color:red;">${keyInfo.key}</span>
	  		</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  		<span>
	  			&nbsp;&nbsp;&nbsp;&nbsp;
	  			查准率（${keyInfo.hitRate*100} %）
	  		</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  		<a href="tviewRandom?keyword=${keyInfo.id}&type=1">换一个</a>
			<table border="0">
				<tr>
					<td style="border:none;">
						<div id="div0" class="containerDiv">
							
						</div>
					</td>
				</tr>
				<tr>
					<td style="border:none;">
						<div id="moreDiv" style="width:925px;margin-left:43px;
						font-size:15px;padding-top:5px;padding-bottom:5px;padding-left:5px;padding-right:5px;
						height:55px;
						background-color:#D2E4F8;text-align:center;
						border-radius:5px;">
							<div id="prev" style="cursor:pointer;float:left;padding-top:20px;height:35px;width:400px;border-radius:8px;background-color:#AECEF2;" onclick="less();">
								上一页
							</div>
							<div id="next" style="cursor:pointer;float:right;padding-top:20px;height:35px;width:400px;border-radius:8px;background-color:#AECEF2;" onclick="more();">
								下一页
							</div>
						</div>
					</td>
				</tr>
			</table>
			
			<div id="floatDiv" style="width:133px;height:450px; position:fixed;left:0px;top:100px;">
				<div>
					<div onclick="listGoods(0, 1);" class="tabTd tabOn" id="tab0">未处理（<span id="unNum">${keyInfo.unhandleNum}</span>）</div>
					<div onclick="listGoods(1, 1);" class="tabTd" id="tab1">正确（<span id="okNum">${keyInfo.effectiveNum}</span>）</div>
					<div onclick="listGoods(2, 1);" class="tabTd" id="tab2">错误（<span id="noNum">${keyInfo.invainNum}</span>）</div>
				</div><br /><hr style="border:1px solid #bbbbbb;border-top:none;" />
				<div><br />
					<div class="link_" onclick="selectAll(1);">全选</div>&nbsp;&nbsp;
					<div class="link_" onclick="selectAll(-1);">反选</div>&nbsp;&nbsp;
					<div class="link_" onclick="selectAll(0);">取消选择</div><br /><br />
					<div class="link_" id="batchNo" style="background-color:red;" onclick="setStatus(2);">批量错误</div>&nbsp;&nbsp;
					<div class="link_" id="batchOk" style="background-color:green;" onclick="setStatus(1);">批量正确</div>
					<div style="margin:auto;width:100px;padding-top:11px;text-align:center;"><a href="#topDiv">回到顶部</a><div>
				</div>
			</div>
	  		<#else>
	  			没有更多信息
  		</#if>
  	</div>
  	<br />
  </body>
</html>
